#ifndef PROJECTMANAGER_H
#define PROJECTMANAGER_H

#include <vector>
#include <QString>
#include <QHash>
#include <QVector>
#include <QStringList>
#include "luafile.h"
#include "settingsmanager.h"
#include "globalsink.h"
#include "htmlbuilder.h"
using namespace std;

class ProjectManager : public GlobalSink, public HtmlBuilder
{
    QVector<LuaFile *> m_files;
    QString m_CSS;
    QHash<QString, QString> m_filesByDirs;
    QString m_currentFile;
    bool m_saved;
    QString m_projectName;    
    QString m_projectFile;
    bool m_isTemporaryProject;
    //QHash<QString, AstNode> m_standardFunctions;
    QStringList m_keywords;
    QString m_fileFilter;
    QString m_removePngData;
    QString m_openPngData;
    QString m_addFilePngData;
    QString m_importPngData;
    QString m_newPngData;
    QString m_newProjectPngData;
public:
    ProjectManager(QString aLastProject);
    ~ProjectManager();    
    LuaFile * getFileByPath(QString aPath);
    void importFilesFromDirectory(QString aDirectory);
    void resetFiles();
    void loadCSS();
    void setCurrentFile(QString aFile);
    int getSuggestions(QStringList & aList, int aOffset, int aCharacter);
    QString getProjectName();
    void setProjectName(QString aName);
    void addEmptyProjectHtml(QStringList & aHtml);
    bool load(QString aFile);
    bool save(QString aFile);
    QString getProjectFile();
    void addFile(QString aPath);
    bool isSaved();
    bool hasFiles();
    bool isTemporaryProject();
    void addListHtmlItem(QString aLink, QString aText, QString aIcon, QStringList &aSink);
    void saveAllFiles();
    bool hasUnsavedFiles();
    void resetProject();
    void excludeFile(QString aFile);
    void excludeDirectory(QString aDirectory);
    void addHeaderHtmlItem(QString aText, QStringList aRightIconList, QStringList aRightIconLinkList, QStringList &aSink);
    bool getWordBoundaries(int aOffset, int &aStart, int &aLength);   
    bool hasGlobal(const QString &aText);
    bool isStandardFunction(const QString &aText);
    void addStandardFunctions();
    void getMatchingStandardFunctions(QString aMatch, QStringList &aList);
    void getMatchingKeywords(QString aMatch, QStringList &aList);
    bool getClickedLink(int aOffset, QStringList &aLinks);
    bool hasGlobalMethod(const QString aText);
    bool hasStandardMethod(const QString aText);
    QString getModifiedWord(int aOffset, int aCharacter);
    void setOffsetForCurrentFile(int aScrollOffset);
    void setFilter(QString aFilter);
    void addNewFile(QString aPath);
    void getAllFiles(QStringList & aList);
    void getAllMatchingGlobals(QString aWord, QStringList &aList, QStringList & aLinks);
    void addProjectHtml(QStringList &aHtml);
    void addContent(QStringList &aHtml);
    bool getClickedLinkWithText(int aOffset, QString aWord, QStringList &aLinks);
signals:
    void fileExcluded(QString);

};

#endif // PROJECTMANAGER_H
